package com.jcooky.tutorfs.proxy.processor.factory;

import com.jcooky.tutorfs.proxy.processor.MessageProcessor;
import com.jcooky.tutorfs.proxy.processor.ReqMkdirProcessor;
import com.jcooky.tutorfs.proxy.processor.ReqReadProcessor;
import com.jcooky.tutorfs.proxy.processor.ReqRmdirProcessor;
import com.jcooky.tutorfs.proxy.processor.ReqWriteProcessor;
import com.jcooky.tutorfs.proxy.protocol.AbstractMessage;
import com.jcooky.tutorfs.proxy.protocol.ReqMkdir;
import com.jcooky.tutorfs.proxy.protocol.ReqRead;
import com.jcooky.tutorfs.proxy.protocol.ReqRmdir;
import com.jcooky.tutorfs.proxy.protocol.ReqWrite;

public class SimpleProcessorFactory extends AbstractProcessorFactory {
	
	private MessageProcessor<ReqMkdir> reqMkdirProcessor = new ReqMkdirProcessor();
	private MessageProcessor<ReqRmdir> reqRmdirProcessor = new ReqRmdirProcessor();
	private MessageProcessor<ReqWrite> reqWriteProcessor = new ReqWriteProcessor();
	private MessageProcessor<ReqRead> reqReadProcessor = new ReqReadProcessor();
	
	public <T extends AbstractMessage> MessageProcessor<T> getProcessor(
			int msgType) {
		switch(msgType) {
		case AbstractMessage.TYPE_REQ_MKDIR:
			return (MessageProcessor<T>)reqMkdirProcessor;
		case AbstractMessage.TYPE_REQ_RMDIR:
			return (MessageProcessor<T>)reqRmdirProcessor;
		case AbstractMessage.TYPE_REQ_WRITE:
			return (MessageProcessor<T>)reqWriteProcessor;
		case AbstractMessage.TYPE_REQ_READ:
			return (MessageProcessor<T>)reqReadProcessor;
		}
		
		return null;
	}

}
